package analisis.matrizContingencia;

import java.util.List;

/**
 * @file SegmentationAccuracy.java
 * @author Juan Humanes Ferrer
 * @date 14-Marzo-2014
 *
 */
public final class SegmentationAccuracy implements IMedida {

    private double segmentationAccuracy;//valor en porcentaje

    public SegmentationAccuracy() {
        setSegmentationAccuracy(0.0);//valor en porcentaje
    }

    /**
     * Método que retorna el segmentationAccuracy
     *
     * @return segmentationAccuracy
     */
    public double getSegmentationAccuracy() {
        return segmentationAccuracy;
    }

    /**
     * Métodod que modifica el valor de segmentationAccuracy
     *
     * @param segmentationAccuracy
     */
    public void setSegmentationAccuracy(double segmentationAccuracy) {
        this.segmentationAccuracy = segmentationAccuracy;
    }

    /**
     * Método que calcula la Specificity
     *
     * @param tp
     * @param tn
     * @param fp
     * @param fn
     * @param valoresMedidas
     */
    @Override
    public void calculaMedida(double tp, double tn, double fp, double fn, List<IMedida> valoresMedidas) {
        double n = tp + tn + fn + fp;
        double result = Double.POSITIVE_INFINITY;

        if (n != 0.0) {
            result = ((tp + tn) / n) * 100.0;
        }

        setSegmentationAccuracy(result);
    }

    @Override
    public Double verValor() {
        return getSegmentationAccuracy();
    }
}
